package com.fh.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fh.service.CustomerService;
import com.fh.mapper.CustomerMapper;
import com.utils.bean.CostomerID;
import com.utils.bean.Customer;
import com.utils.bean.CustomerPage;
import com.utils.bean.User;
import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【customer】的数据库操作Service实现
* @createDate 2023-05-10 10:40:28
*/
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
implements CustomerService{


    @Autowired
    private CustomerMapper customerMapper;
    /**
     * @param customer
     * @return java.util.List<com.utils.bean.Customer>
     * @description: 查询账户名下的客服
     * @author whf
     * @date 2023/5/10 18:16
     */
    @Override
    public Page<Customer> getCustomer(CustomerPage customer) {
        Page<Customer> userPage = new Page<>(customer.getPageNum(), customer.getPageSize());
        if(customer.getPageSize() == 0) {
            customer.setUserID(null);
        }
        customerMapper.getCustomer(userPage,customer.getUserID());
        return userPage;
    }

    /**
     * @param customer
     * @return com.baomidou.mybatisplus.extension.plugins.pagination.Page<com.utils.bean.User>
     * @description: 如果是老板可以查询全部
     * @author whf
     * @date 2023/5/17 14:33
     */
    @Override
    public Page<Customer> getBoss(CustomerPage customer) {
        Page<Customer> userPage = new Page<>(customer.getPageNum(), customer.getPageSize());
        customerMapper.getBoss(userPage);
        return userPage;
    }

    /**
     * @param
     * @description: 对他进行删除
     * @author whf
     * @date 2023/5/17 9:17
     */
    @Override
    public void delCustomer(CostomerID costomerID) {
        customerMapper.deleteById(costomerID.getId());
    }

    /**
     * @param
     * @description: 删除一群人
     * @author whf
     * @date 2023/5/17 9:18
     */
    @Override
    public void delCustomers(List<CostomerID> costomerIDS) {
        customerMapper.deleteBatchIds(costomerIDS);
    }

    /**
     * @param customer
     * @return java.util.List<com.utils.bean.Customer>
     * @description: 根据名字 性别之类的查询
     * @author whf
     * @date 2023/5/17 10:29
     */
    @Override
    public List<Customer> getCustomerIF(Customer customer) {
        return customerMapper.getCustomerIF(customer);
    }


}
